import BaseLayout from '@/views/index.vue';
import { createRouter, createWebHistory } from 'vue-router';

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      redirect: '/home',
      component: BaseLayout,
      children: [
        {
          path: '/home',
          name: 'Home',
          component: () => import('@/views/Home/index.vue'),
          meta: {
            title: '首页',
            icon: 'HomeFilled'
          }
        },
        {
          path: '/richEditor',
          name: 'RichEditor',
          component: () => import('@/views/RichEditor/index.vue'),
          meta: {
            title: '富文本编辑器',
            icon: 'Edit'
          },
          children: [
            {
              path: 'markdownEditor',
              name: 'MarkdownEditor',
              component: () => import('@/views/RichEditor/MarkdownEditor/index.vue'),
              meta: {
                title: 'Markdown编辑器',
                icon: 'Menu'
              }
            }
          ]
        },
        {
          path: '/chart',
          name: 'Chart',
          component: () => import('@/views/Chart/index.vue'),
          meta: {
            title: '图表',
            icon: 'DataLine'
          },
          children: [
            {
              path: 'basicChart',
              name: 'BasicChart',
              component: () => import('@/views/Chart/BasicChart/index.vue'),
              meta: {
                title: '基础图表',
                icon: 'Menu'
              }
            },
            {
              path: 'chinaMap',
              name: 'ChinaMap',
              component: () => import('@/views/Chart/ChinaMap/index.vue'),
              meta: {
                title: '中国地图',
                icon: 'Menu'
              }
            }
          ]
        },
        {
          path: '/richTable',
          name: 'RichTable',
          component: () => import('@/views/RichTable/index.vue'),
          meta: {
            title: '富表格',
            icon: 'IceCream'
          }
        },
        {
          path: '/iconList',
          name: 'IconList',
          component: () => import('@/views/IconList/index.vue'),
          meta: {
            title: '图标列表',
            icon: 'ElementPlus'
          }
        }
      ]
    },
    {
      path: '/login',
      name: 'Login',
      component: () => import('@/views/Login/index.vue'),
      meta: {
        title: '登录'
      }
    },
    {
      path: '/:pathMatch(.*)*',
      name: '404',
      component: () => import('@/views/404/index.vue'),
      meta: {
        title: '404'
      }
    }
  ]
});

export default router;
